home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
prog_c
/
cuj0696.zip
/
DWYER.ZIP
/
SPECTRAL.TST
/
CALCMERT.CX
next >
Wrap
Text File
|
1996-03-14
|
1KB
|
51 lines
/* ============ */
/* calcmert.c */
/* ============ */
#include <xtendefs.h>
#define ODD(n) ((n) & 1)
/* ==================================================================== */
/* CalcMerit - Calculates Merit for given Accuracy, Dimension, Modulus */
/* ==================================================================== */
void
CalcMerit(USHORT *XS, short N, USHORT *Modulus, USHORT *Merit)
{
USHORT AccP[NE];
USHORT Fac[NE];
USHORT PiP[NE];
USHORT Term[NE];
USHORT Tmp1[NE];
USHORT Xn[NE], HalfXn[NE];
long TmpLng = N;
LONGTOX(TmpLng, Xn); /* N to extended */
XMULT(Xn, EHALF, HalfXn); /* HalfXn = N/2 */
XPOW(XS, HalfXn, AccP);
XCOPY(EONE, Fac);
XCOPY(HalfXn, Term);
P(XPRINTF("CalcMert: First Term = ", Term, NDEC));
while (XGTE(Term, EHALF))
{
XMULT(Fac, Term, Fac);
XSUB(Term, EONE, Term);
P(XPRINTF("\t Next Term = ", Term, NDEC));
}
if (ODD(N))
{
XRSUB(HalfXn, EHALF); /* HalfXn -= 1/2 */
}
else
{
/* N/2 Already Calculated */
}
XPOW(EPI, HalfXn, PiP);
XMULT(PiP, AccP, Tmp1);
XRDIV(Tmp1, Fac);
XDIV(Tmp1, Modulus, Merit);
}